<?php
namespace Common\Model;
use Common\Model\CommonModel;
class UserPurseModel extends CommonModel{
       function  getCreditValue($uid){
           // $uid = I('uid');
            $app_user = M('app_users');
            $purse = M("user_purse");
            $time = $app_user->where(array('user_id'=>$uid))->getField('regist_time');
            $time = strtotime($time);

            $result = $purse->field('purse_amount')->where('purse_type=2')->select();
            $money_count = 0;
            foreach ($result as $key =>$value)
            {
                $money_count += $value["purse_amount"];
            }
            $now = strtotime(date('Y-m-d'));
            $day = ($now-$time)/60/60/24;
            $cre_value = floor($money_count/$day);
            return $cre_value;   
        }
}